package com.rj.framework.biz.validation;

import com.rj.framework.validation.ContextAwareValidation;
import com.rj.framework.validation.ContextAwareValidator;
import jakarta.validation.ConstraintValidatorContext;

import java.util.Map;

/**
 * 租户资源验证器（需访问上下文）
 */
@ContextAwareValidation
public class TenantResourceValidator extends ContextAwareValidator<TenantResource, String> {
    @Override
    public boolean isValid(String resourceId, ConstraintValidatorContext context) {
        // 检查资源是否属于当前租户
        String currentTenantId = getContext().getGlobalContext().getUserContext().getTenantId();
        Map<String, Object> parameters = getParameters();
         // 调用资源服务检查权限
        //ResourceService resourceService = getGlobalContext().getBean(ResourceService.class);
        // String resourceTenantId = resourceService.getTenantId(resourceId);

        return currentTenantId.equals("resourceTenantId");
    }
}
    